import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入页面组件
import Index from '../views/index.vue'
import Category from '../views/category.vue'
import Detail from '../views/detail.vue'
import Agents from '../views/agents.vue'
import Page from '../views/page.vue'
import Property from '../views/property.vue'
import Comment from '../views/comment.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect:'/index',
    component:Comment,
    // 配置嵌套页面
    children:[
      {
        path:'/index',
        component:Index
      },
      {
        path:'/category',
        component:Category
      },
      {
        path:'/detail',
        component:Detail
      },
      {
        path:'/agents',
        component:Agents
      },
      {
        path:'/page',
        component:Page
      },
      {
        path:'/property',
        component:Property
      }
    ]
  }
]

const router = new VueRouter({
  routes
})



const routerReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function (location) {
  return routerReplace.call(this, location).catch(error => error)
}

export default router

